package com.lagou.callbackconfig;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @Description: 消息发送到交换机确认机制
 * @Author: qjc
 * @Date: 2021/12/9
 */
@Component
@Slf4j
public class MsgSendConfirmCallback implements RabbitTemplate.ConfirmCallback {

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            log.debug("消息发送到exchange成功,id: {}", correlationData.getId());
        } else {
            log.debug("消息{}发送到exchange失败,原因: {}", correlationData.getId(), cause);
        }
    }
}
